//
//  SLWealthChannelComponent.m
//  SulitLoanDemo
//
//  Created by 虞嘉伟 on 2025/2/19.
//


#import "SLWealthChannelComponent.h"
#import <YYKit.h>
#import <Masonry.h>


@interface SLWealthChannelComponent ()
@property (nonatomic, strong) UIView *container;
@end

@implementation SLWealthChannelComponent

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = UIColorHex(#FFE0EF);
        self.layer.cornerRadius = 20;
        self.layer.borderColor = UIColorHex(#FFFFFF).CGColor;
        self.layer.borderWidth = 2;
        
        
        [self addSubview:self.container];
        [self addSubview:self.titleLabel];
        [self addSubview:self.icon];
        [self.container mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.equalTo(self);
            make.centerX.equalTo(self);
        }];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.container);
            make.centerY.equalTo(self.container);
        }];
        [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.titleLabel.mas_right).offset(10);
            make.right.equalTo(self.container);
            make.centerY.equalTo(self.container);
            make.width.height.mas_equalTo(22);
        }];
    }
    return self;
}

- (UIView *)container {
    if (!_container) {
        _container = [UIView new];
    }
    return _container;
}
- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel new];
        _titleLabel.textColor = UIColorHex(#1B1B1B);
        _titleLabel.font = aspectDefaultFont(16);
        _titleLabel.text = @"Open the way to wealth";
    }
    return _titleLabel;
}
- (UIImageView *)icon {
    if (!_icon) {
        _icon = [UIImageView new];
        _icon.contentMode = UIViewContentModeScaleAspectFit;
        _icon.image = [UIImage imageNamed:@"btn_more_white"];
    }
    return _icon;
}
@end
